package imp

import (
	"bgs/cache/redisImp"
	"bgs/conf"
	"bgs/db"
	"bgs/grpc/client"
	userGrpc "bgs/grpc/gen/service/user"
	userFanGrpc "bgs/grpc/gen/service/user_fan"
	userFollowGrpc "bgs/grpc/gen/service/user_follow"
	userPvLogGrpc "bgs/grpc/gen/service/user_pv_log"
	grpcUtil "bgs/grpc/imp/util"
	userService "bgs/service/user"
	"bgs/util"
	"context"
	"go.uber.org/zap"
)

// UserAPIService :grpc server proxy of user
type UserAPIService struct {
	dao  *db.PgDao
	slog *zap.SugaredLogger
	userGrpc.UserOpServer
	userFanGrpc.UserFanOpServer
	userFollowGrpc.UserFollowOpServer
	userPvLogGrpc.UserPvLogOpServer
	pgErrorChecker *grpcUtil.PgErrorChecker
	userService    *userService.UserServiceImp
}

// NewUserAPIService initialization
func NewUserAPIService(
	pgdao *db.PgDao,
	slog *zap.SugaredLogger,
	vars *conf.VarsSection,
	proxy *client.GrpcClientProxy,
	adp *cache.Adapter,
	pgErrorChecker *grpcUtil.PgErrorChecker,
	userService *userService.UserServiceImp,
) *UserAPIService {
	return &UserAPIService{
		dao:            pgdao,
		slog:           slog.With("module", "UserAPIService"),
		pgErrorChecker: pgErrorChecker,
		userService:    userService,
	}
}

// NewContextLogger create a SugaredLogger with contextvalue
func (s *UserAPIService) NewContextLogger(ctx context.Context) *zap.SugaredLogger {
	return util.NewContextLogger(ctx, s.slog)
}
